package com.chefu.operator.vo;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 用来封装前端传递过来的查询参数
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class QueryArticlesRequest {
    private Long page;
    private Integer rows;
    private String title;
    private Long category;
    private Long releaser;
    private Integer status;
    private String startTime;
    private String endTime;
    private static final Integer DEFAULT_SIZE = 15;//如果不传参数，每页默认条数15
    private static final Long DEFAULT_PAGE = 1L;//如果不传参数，默认页第一页


    public void setPage(Long page) {
        this.page = page;
    }

    public Long getPage() {
        if (page == null) {
            return DEFAULT_PAGE;
        }
        //获取页码是做校验，不能小于1
        return Math.max(DEFAULT_PAGE, page);
    }

    public void setRows(Integer rows) {
        this.rows = rows;
    }

    public Integer getRows() {
        if (rows == null) {
            return DEFAULT_SIZE;
        }
        return this.rows = rows;
    }
}
